package com.qwz.example;

import com.qwz.example.component.Component;
import com.qwz.example.component.ConcreteComponent;

/**
* @Description: 使用装饰模式的客户端
* @Package com.qwz.example.Client
* @author Qiuwuzhi
* @date 2019/12/19 13:51
* @version V1.0
*/
public class Client {
    public static void main(String[] args){
        //先创建计算基本奖金的类，这也是被装饰的对象
        Component component = new ConcreteComponent();

        //然后对计算的基础奖金进行装饰，这里要组合各个装饰
        //说明，各个装饰者之间最好是不要有先后顺序的限制
        //也就是先装饰谁和后装饰谁都应该是一样

        //先组合普通业务人员的奖金计算
        Decorator monthPrizeDecorator = new MonthPrizeDecorator(component);
        Decorator sumPrizeDecorator = new SumPrizeDecorator(monthPrizeDecorator);

//        Decorator sumPrizeDecorator = new SumPrizeDecorator(component);
//        Decorator monthPrizeDecorator = new MonthPrizeDecorator(sumPrizeDecorator);

//        double zs =  monthPrizeDecorator.calcPrize("张三", null, null);

        //注意：这里只需要使用最后组合好的对象调用物业方法即可,会依次调用回去
        //日期对象都没用上，传null即可
        double zs = sumPrizeDecorator.calcPrize("张三", null, null);
        System.out.println("======张三的应得奖金"+zs);
        double ls = sumPrizeDecorator.calcPrize("李四", null, null);
        System.out.println("======李四的应得奖金"+ls);

        //业务经理，还需要计算团队的奖金
        Decorator groupPrizeDecorator = new GroupPrizeDecorator(sumPrizeDecorator);
        double ww = groupPrizeDecorator.calcPrize("王五", null, null);
        System.out.println("======王五经理的应得奖金"+ww);

    }
}
